function Ajax(Url, Method){
	this.Url 	= Url==undefined ? '':Url;
	this.Metodo = Method=='POST' ? "POST":"GET";
	this.Data 	= new Array();
	this.execute = HttpExecute;
	this.add = HttpAdd;
	this.Error="";
	this.Funcion = FuncionDefault;
	this.anexo = null;
	this.anexo1 = null;
	this.Sincrono=true;
	this.Xml=false;
	this.Request = false;
	this.getRequest = function (){return this.Request;}
	if (window.XMLHttpRequest) {
		try {this.Request = new XMLHttpRequest();}
		catch(e) {		Request = null;		}
	} else if (window.ActiveXObject) {
		try { 	this.Request = new ActiveXObject("Msxml2.XMLHTTP");}
		catch(e) {
			try {this.Request = new ActiveXObject("Microsoft.XMLHTTP");	}
			catch(e) {		this.Request = null;							}
		}
	}
}
function HttpAdd(Variable, Valor){
	this.Data.push(new Pares(Variable,Valor));
}
function HttpExecute(){
	var Request_fun;
	var Request_Xml;
	var sURL;
	var sSend;
	
	//alert (Request);
	try {
		var Send = "1";
		for(var i in this.Data) {
			Send +="&"+this.Data[i].namevar+"="+this.Data[i].value;
		}
		if (this.Metodo=="GET") {sURL=this.Url+(this.Data.length>0?"?"+Send:""); 	sSend="";}
						else	{sURL=this.Url;				sSend=Send;}
		//alert ("url.>"+this.Url);
		this.Request.open(this.Metodo, sURL, this.Sincrono);//alert (this.Metodo +":"+ sURL +":"+ this.Sincrono)		
		if (this.Sincrono==true){
			//f = this.Funcion;
			//Request.Xml="ASDSAD";
			//Request.fun = function (){alert('asdsad')}
			//Request.fun=this.Funcion;
			//Request.Xml=this.Xml;
			Request_fun=this.Funcion;
			Request_Xml=this.Xml;
			//alert (this.parent)
			//Request["xml"] = "asdasd";
			//alert("probando!!");
			//Request.prototype.xml = this.Xml;
	//		Request.prototype.xml = "SDASD";
			//alert(Property.xml);
			//Request.onreadystatechange = function (){ FuncionDefault(Request, Request_fun, Request_Xml);}
			var funciones = this.Funcion;
			var anexo = this.anexo
			var anexo1 = this.anexo1
			//Request.onreadystatechange = function (){ this.Funcion();}
			this.Request.onreadystatechange = function (){ funciones(this, anexo, anexo1);}
			//loadMenu(rq)
			//function(){FuncionDefault(Request);}
			//this.Request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			this.Request.setRequestHeader('Content-Type','text/plain; charset=utf-8');
			this.Request.send(sSend);
			//alert("Llego21");
		}
		else{
			this.Request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			this.Request.send(sSend);
			if (this.Request.readyState==4){
				if(this.Request.status==200) {
					var response = Request.responseText;
					return response;
				}
				else {
					alert('El servidor responde con un codigo de estado erróneo: '+Request.statusText);
				}
			}
		}
	}	
	catch (e){	
		this.Error += "\n*Error en el Corazon: Error en la funcion HttpExecute:\n "+e;
		alert ("Error en el Corazon" + e)
	}
}
function FuncionDefault(Rq, f_Funcion, c_Xml) {
	if (Rq.readyState==4){
		if(Rq.status==200) {
			//if (Rq.Xml=="true")	var response = Rq.responseXML;
			if (c_Xml=="true")	var response = Rq.responseXML;
			else				var response = Rq.responseText;
			if (f_Funcion!=FuncionDefault) f_Funcion(response);
			else alert ("No hay funcion de Respuesta definida. El Pedido retorno es: \n\n"+response)
		}
		else {
			this.Error +="\n*Error al Recibir:El servidor responde con un codigo de estado erróneo: "+Rq.statusText;
			alert("Error al Recibir");
			Rq.fun("false", "Codigo de Estado Erroneo"+Rq.statusText);
		}
	}
}
function Pares(Variable,Valor) {
	this.namevar = Variable;
	this.value = Valor;
}